package com.diver.flinkdemo.entity.xxt;/**
 * @author yangs
 */

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Setter;

/**
 * 晓羊结果
 * @author yangs
 */
//@Getter
@Setter
public class XyResult {
    private Integer RESULT;

    private Integer ERRORCODE;

    private String ERRORDESC;

    @JSONField(name = "RESULT")
    public Integer getRESULT() {
        return RESULT;
    }

    @JSONField(name = "ERRORCODE")
    public Integer getERRORCODE() {
        return ERRORCODE;
    }

    @JSONField(name = "ERRORDESC")
    public String getERRORDESC() {
        return ERRORDESC;
    }

    public XyResult(Integer RESULT, Integer ERRORCODE, String ERRORDESC) {
        this.RESULT = RESULT;
        this.ERRORCODE = ERRORCODE;
        this.ERRORDESC = ERRORDESC;
    }

    @Override
    public String toString() {
        return "XyResult{" +
                "RESULT=" + RESULT +
                ", ERRORCODE=" + ERRORCODE +
                ", ERRORDESC='" + ERRORDESC + '\'' +
                '}';
    }

    public static XyResult success(){
        return new XyResult(0, 0, "正确执行");
    }

    public static XyResult paramsFail(){
        return fail( 1, "参数错误");
    }

    public static XyResult paramsFail(String desc){
        return fail( 1, desc);
    }

    public static XyResult authFail(){
        return fail(2, "不合法的身份");
    }

    public static XyResult secretFail(){
        return fail(3, "appSecret 错误");
    }

    public static XyResult valideFail(){
        return fail(4, "校验错误");
    }


    public static XyResult timeOutFail(){
        return fail(5, "超时错误");
    }

    public static XyResult duplicateFencyIdFail(){
        return fail(6, "重复的围栏 ID 错误");
    }

    public static XyResult notFundFencyIdFail(){
        return fail(7, "围栏 ID 不存在");
    }

    public static XyResult otherFail(){
        return fail(255, "其他错误");
    }

    public static XyResult fail(Integer errorCode, String errDesc){
        return new XyResult(1, errorCode, errDesc);
    }

}
